#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

class InsertSort
{
public:
	InsertSort(int* a, int n)
	{
		for (int i = 0; i < n - 1; i++)
		{
			int end = i;
			int tmp = a[i + 1];

			while (end >= 0 && a[end] > tmp)
			{
				a[end + 1] = a[end];
				end--;
			}
			a[end + 1] = tmp;
		}
	}
};

int main()
{
	int a[] = {1, 2, 1, 7, 5, 4};
	int n = sizeof(a) / sizeof(a[0]);

	InsertSort insort(a, n);

	for (int i = 0; i < n; i++)
	{
		cout << a[i] << ' ';
	}
	return 0;
}